<?php
/**
 * Created by PhpStorm.
 * User: hui
 * Date: 2017/2/19
 * Time: 13:12
 */
namespace app\admin\validate;

class Admin extends Base
{
    protected $rule = [
        'name'     => 'require|length:4,32|unique:admin',
        'nickname' => 'require|max:32',
        'password' => 'require|confirm',
        'email'    => 'filter:validate_email',
        'role'     => 'require|number',
        'captcha'  => 'require|captcha'
    ];

    protected $message = [
        'name.token'       => '非法请求',
        'name.unique'      => '用户名已存在',
        'name.require'     => '用户名未填写',
        'name.length'      => '用户名长度必须为4到32位',
        'password.require' => '密码未填写',
        'password.confirm' => '两次输入密码不一致',
        'captcha.require'  => '验证码未填写',
        'captcha.captcha'  => '验证码错误'
    ];

    protected $scene = [
        'login' => ['name' => 'require|length:4,32|token', 'password' => 'require', 'captcha'],
        'add'  => ['name', 'nickname', 'password', 'email', 'role'],
        'edit'  => ['name', 'nickname', 'email', 'role']
    ];
}